package action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.heantai.easystruts.controller.Action;
import com.heantai.easystruts.form.ActionForm;

import form.CommentForm;

public class CommentAction extends Action {

	@Override
	public String execute(ActionForm actionForm,HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		CommentForm commentForm = (CommentForm)actionForm;
		HttpSession session = request.getSession();
		String validateCodeOfSession = (String) session
				.getAttribute("validateCode");
		String validateCode = commentForm.getValidateCode().toUpperCase();
		if (!validateCodeOfSession.equals(validateCode)) {
			request.setAttribute("validateCodeErr", "验证码错误");
			return "validateCodeErr";
		}
		String title=commentForm.getTitle();
		String content=commentForm.getContent();
		request.setAttribute("title", title);
		request.setAttribute("content", content);
		return "comment";
	}

}
